/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MemberForm.java
 *
 * Created on 23-03-2011, 22:31:56
 */
package tiebreak.UI;

import tiebreak.BE.Member;
import tiebreak.BL.Accounting;
import tiebreak.BL.EasyException;
import tiebreak.BL.MemberWorker;
import tiebreak.be.Fee;

/**
 *
 * @author AngelwingedDevil
 */
public class MemberDetails extends javax.swing.JPanel
{
    private Member member;

    /** Creates new form MemberForm */
    public MemberDetails(int ID) throws EasyException
    {
        initComponents();
        setMember(ID);
        setTextLabaels(ID);

        return;
    }
public Member getMember()
    {
    return member;
}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        txtlbl_firstName = new javax.swing.JLabel();
        txtlbl_lastName = new javax.swing.JLabel();
        txtlbl_address = new javax.swing.JLabel();
        txtlbl_zipcode = new javax.swing.JLabel();
        txtlbl_cpr = new javax.swing.JLabel();
        txtlbl_phone = new javax.swing.JLabel();
        txtlbl_email = new javax.swing.JLabel();
        txtlbl_Type = new javax.swing.JLabel();
        txtlbl_memberID = new javax.swing.JLabel();
        txtlbl_city = new javax.swing.JLabel();
        txtlbl_isElite = new javax.swing.JLabel();
        txtlbl_training = new javax.swing.JLabel();
        txtlbl_isCoach = new javax.swing.JLabel();
        lbl_memberID = new javax.swing.JLabel();
        lbl_firstName = new javax.swing.JLabel();
        lbl_lastName = new javax.swing.JLabel();
        lbl_cpr = new javax.swing.JLabel();
        lbl_address = new javax.swing.JLabel();
        lbl_zipcode = new javax.swing.JLabel();
        lbl_city = new javax.swing.JLabel();
        lbl_phone = new javax.swing.JLabel();
        lbl_email = new javax.swing.JLabel();
        lbl_typeID = new javax.swing.JLabel();
        lbl_isElite = new javax.swing.JLabel();
        lbl_underSchoolTraining = new javax.swing.JLabel();
        txtlbl_pays = new javax.swing.JLabel();
        lbl_pays = new javax.swing.JLabel();
        lbl_isCoach = new javax.swing.JLabel();

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(jList1);

        txtlbl_firstName.setText("First Name:");

        txtlbl_lastName.setText("Last Name:");

        txtlbl_address.setText("Address:");

        txtlbl_zipcode.setText("Zipcode:");

        txtlbl_cpr.setText("CPR no.:");

        txtlbl_phone.setText("Phone no:");

        txtlbl_email.setText("Email:");

        txtlbl_Type.setText("Type:");

        txtlbl_memberID.setText("Squintial no.:");

        txtlbl_city.setText("City:");

        txtlbl_isElite.setText("Elite:");

        txtlbl_training.setText("Training:");

        txtlbl_isCoach.setText("Is a coach:");

        lbl_memberID.setText("MemberID...");

        lbl_firstName.setText("First Name...");

        lbl_lastName.setText("Last Name...");

        lbl_cpr.setText("Cpr...");

        lbl_address.setText("Address...");

        lbl_zipcode.setText("Zipcode...");

        lbl_city.setText("City...");

        lbl_phone.setText("Phone..");

        lbl_email.setText("Email...");

        lbl_typeID.setText("Type...");

        lbl_isElite.setText("Elite...");

        lbl_underSchoolTraining.setText("Training...");

        txtlbl_pays.setText("Pays:");

        lbl_pays.setText("Pays...");

        lbl_isCoach.setText("Coach...");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtlbl_memberID)
                    .addComponent(txtlbl_firstName)
                    .addComponent(txtlbl_phone)
                    .addComponent(txtlbl_email)
                    .addComponent(txtlbl_Type)
                    .addComponent(txtlbl_isElite)
                    .addComponent(txtlbl_training)
                    .addComponent(txtlbl_isCoach)
                    .addComponent(txtlbl_pays)
                    .addComponent(txtlbl_lastName)
                    .addComponent(txtlbl_city)
                    .addComponent(txtlbl_zipcode)
                    .addComponent(txtlbl_address)
                    .addComponent(txtlbl_cpr))
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbl_isCoach, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_typeID, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_email, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_phone, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_memberID, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_city, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_address, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_zipcode, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_isElite, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_underSchoolTraining, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_pays, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_firstName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_lastName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(lbl_cpr, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_memberID)
                            .addComponent(lbl_memberID))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_firstName)
                            .addComponent(lbl_firstName))
                        .addGap(42, 42, 42)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_cpr)
                            .addComponent(lbl_cpr))
                        .addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_address)
                            .addComponent(lbl_address))
                        .addGap(13, 13, 13)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_zipcode)
                            .addComponent(lbl_zipcode))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_city)
                            .addComponent(lbl_city))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_phone)
                            .addComponent(lbl_phone))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_email)
                            .addComponent(lbl_email))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_Type)
                            .addComponent(lbl_typeID))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_isElite)
                            .addComponent(lbl_isElite))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_training)
                            .addComponent(lbl_underSchoolTraining))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_isCoach)
                            .addComponent(lbl_isCoach, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(72, 72, 72)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlbl_lastName)
                            .addComponent(lbl_lastName, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtlbl_pays)
                    .addComponent(lbl_pays))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbl_address;
    private javax.swing.JLabel lbl_city;
    private javax.swing.JLabel lbl_cpr;
    private javax.swing.JLabel lbl_email;
    private javax.swing.JLabel lbl_firstName;
    private javax.swing.JLabel lbl_isCoach;
    private javax.swing.JLabel lbl_isElite;
    private javax.swing.JLabel lbl_lastName;
    private javax.swing.JLabel lbl_memberID;
    private javax.swing.JLabel lbl_pays;
    private javax.swing.JLabel lbl_phone;
    private javax.swing.JLabel lbl_typeID;
    private javax.swing.JLabel lbl_underSchoolTraining;
    private javax.swing.JLabel lbl_zipcode;
    private javax.swing.JLabel txtlbl_Type;
    private javax.swing.JLabel txtlbl_address;
    private javax.swing.JLabel txtlbl_city;
    private javax.swing.JLabel txtlbl_cpr;
    private javax.swing.JLabel txtlbl_email;
    private javax.swing.JLabel txtlbl_firstName;
    private javax.swing.JLabel txtlbl_isCoach;
    private javax.swing.JLabel txtlbl_isElite;
    private javax.swing.JLabel txtlbl_lastName;
    private javax.swing.JLabel txtlbl_memberID;
    private javax.swing.JLabel txtlbl_pays;
    private javax.swing.JLabel txtlbl_phone;
    private javax.swing.JLabel txtlbl_training;
    private javax.swing.JLabel txtlbl_zipcode;
    // End of variables declaration//GEN-END:variables

    private void setTextLabaels(int ID) throws EasyException
    {
        MemberWorker m_worker = new MemberWorker();
        Member member;

        if (ID > 4)
        {
            member = m_worker.getMemberWithCpr(ID);
        }
        else
        {
            member = m_worker.getMemberWithMemberID(ID);
        }




        //fee = a_worker.getPriceByType(member.getTypeID()); //Need the type in Accounting to be changed to an integer!!!

        setTextMemberID(member.getMemberID());
        setTextFirstName(member.getFirstName());
        setTextLastName(member.getLastName());
        setTextAddress(member.getAddress());
        setTextZipcode(member.getZipcode());
        setTextCpr(member.getCpr());
        setTextPhone(member.getPhone());
        setTextEmail(member.getEmail());
        setTextTypeID(member.getTypeID());
        setTextIsElite(member.getIsElite());
        setTextTraining(member.getUnderSchoolTraining());
        setTextIsCoach(member.getIsCoach());
//        setTextCity(zipcode.getCity());
        setTextPays();
    }

    private void setTextMemberID(int memberID)
    {
        lbl_memberID.setText(Integer.toString(memberID));


    }

    private void setTextFirstName(String firstName)
    {
        lbl_firstName.setText(firstName);


    }

    private void setTextLastName(String lastName)
    {
        lbl_lastName.setText(lastName);


    }

    private void setTextCpr(int cpr)
    {
        lbl_cpr.setText(Integer.toString(cpr));


    }

    private void setTextAddress(String address)
    {
        lbl_address.setText(address);


    }

    private void setTextZipcode(int zipcode)
    {
        lbl_zipcode.setText(Integer.toString(zipcode));


    } //    private void setTextCity(String city)
    //    {
    //        lbl_city.setText(city);
    //    }

    private void setTextPhone(int phone)
    {
        lbl_phone.setText(Integer.toString(phone));


    }

    private void setTextEmail(String email)
    {
        lbl_email.setText(email);


    }

    private void setTextTypeID(int typeID)
    {
        lbl_typeID.setText(Integer.toString(typeID));


    }

    private void setTextIsElite(boolean isElite)
    {
        if (isElite == true)
        {
            lbl_isElite.setText("Yes");


        }
        else
        {
            lbl_isElite.setText("No");


        }
    }

    private void setTextTraining(boolean underSchoolTraining)
    {
        if (underSchoolTraining == true)
        {
            lbl_underSchoolTraining.setText("Yes");


        }
        else
        {
            lbl_underSchoolTraining.setText("No");


        }
    }

    private void setTextIsCoach(boolean isCoach)
    {
        if (isCoach == true)
        {
            lbl_isCoach.setText("Yes");


        }
        else
        {
            lbl_isCoach.setText("No");


        }
    }

    private void setTextPays(int pays)
    {
        lbl_pays.setText(Integer.toString(pays));

    }

    private void setMember(int id) throws EasyException
    {
        MemberWorker mw = new MemberWorker();
        member = mw.getMemberWithMemberID(id);
    }
}
